package softstarter.gui.subareas;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;


public class ButtonFactory {
    
    @Deprecated
    public JButton getNewIconlessButton(String actionCommand, String tooltipText, int width, int height) {
        JButton button = new JButton();
//        button.setPreferredSize(new Dimension(width, height));
//        button.setMaximumSize(new Dimension(width, height));
        button.setActionCommand(actionCommand);
        button.setName(actionCommand);
        button.setToolTipText(tooltipText);

        return button;

    }
    
    public JButton getNewIconButton(String actionCommand, String imagePath, String tooltipText) {
        JButton button = new JButton(getIconFor(imagePath));
        button.setPreferredSize(new Dimension(button.getIcon().getIconWidth() + 0, button.getIcon().getIconHeight() + 0));
        button.setMaximumSize(new Dimension(button.getIcon().getIconWidth() + 0, button.getIcon().getIconHeight() + 0));
//        button.setPreferredSize(new Dimension(48, 48));
//        button.setMaximumSize(new Dimension(48, 48));
        button.setActionCommand(actionCommand);
        button.setName(actionCommand);
        button.setToolTipText(tooltipText);

        return button;
    }
    
    public JLabel getImageLabel(String imagePath) {
        return new JLabel(getIconFor(imagePath));
    }
    
    private Icon getIconFor(String imagePath) {
        return new ImageIcon(Toolkit.getDefaultToolkit().getImage(imagePath));
    }
    
}
